package com.example.demo2.controller;

import com.example.demo2.entity.Person;
import com.example.demo2.service.PersonService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/person")
public class PersonController {
    @Resource
    private PersonService personService;

    @RequestMapping(value = "/find")
    public String findAllPerson(@RequestParam("id") Integer id) {
        return personService.findOne(id);
    }

    @RequestMapping(value = "/add")
    public String addPerson(Person person) {
        return personService.save(person);
    }

    @RequestMapping(value = "/del")
    public String delPerson(@RequestParam("id") Integer id) {
        return personService.delete(id);
    }
}
